--首次使用备份数据
CREATE OR REPLACE PROCEDURE
BACKUP_DATA AUTHID CURRENT_USER
IS
  CURSOR C1 
  IS 
  SELECT 
    * 
  FROM USER_TABLES 
  WHERE TABLE_NAME IN ('PDS_DIRS_HISTORYLIST', 'PDS_PARTS_HISTORYLIST', 'PDS_DIRS_PARTS', 'PDS_PARTS_PART');

  CURSOR C2 IS SELECT * FROM USER_TABLES WHERE TABLE_NAME LIKE 'BAK%';
  V_SQL VARCHAR2(1000);

BEGIN
  FOR V_R IN C2
  LOOP
    V_SQL := 'DROP TABLE ' || V_R.TABLE_NAME;
    EXECUTE IMMEDIATE V_SQL;
  END LOOP;

  FOR V_R IN C1
  LOOP
    V_SQL := 'CREATE TABLE BAK_' || V_R.TABLE_NAME || ' AS SELECT * FROM ' || V_R.TABLE_NAME;
    EXECUTE IMMEDIATE V_SQL;
  END LOOP;

  COMMIT;
  
END;